import requests

url = "https://ifconfig.co/json"
response = requests.get(url)
data = response.json()

# Parse JSON response
ip = data["ip"]
city = data.get("city", "Unknown")
country = data.get("country", "Unknown")

print(f"Public IP: {ip}, City: {city}")
print(f"City: {city}")
print(f"Country: {country}")